<?php
/**
 * Ganglib
 *
 * LICENSE
 *
 * This source file is subject to the GNU Lesser Generak Public license.
 * 
 * It is available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/lgpl.html
 *
 * @category    Ganglib
 * @package    Div_Db_Distributor_Strategy
 * @copyright  Copyright (c) 2008 Ganglib project members (http://www.code.google.com/p/ganglib)
 * @license     http://www.gnu.org/licenses/lgpl.html
 */
 
 
/**
 * Abstract Strategy class
 * It's base class for all database strategies. 
 * 
 * @package    Div_Db_Distributor_Strategy
 * @copyright  Copyright (c) 2008 Ganglib project members (http://www.code.google.com/p/ganglib)
 * @license     http://www.gnu.org/licenses/lgpl.html
 */
abstract class Div_Db_Distributor_Strategy_Abstract
{
	/**
	 * Configuration
	 *
	 * @var Zend_Config
	 */
	protected $_config;
	
	/**
	 * Connection schemas for strategies
	 *
	 * @var Zend_Config
	 */
	protected $_schemas;
	
	/**
	 * Is last executeQuery cacheable?
	 *
	 * @var bool
	 */
	public $isCacheable = true;
	
	/**
	 * Constructor
	 *
	 * @param Zend_Config $config
	 * @access public
	 * @return void
	 */
	public function __construct($config = null)
	{	
		if($config)
			$this->_config = $config->strategies;
			
		$this->_schemas = $config->schemas;
	}
	
	/**
	 * Execute query
	 *
	 * @param Div_Db_Query $query
	 * @return mixed
	 * @access public
	 */
	public function execute($query)
	{
		return null;
	}
	
	/**
     * Throw an exception
     *
     * Note : for perf reasons, the "load" of Zend/Cache/Exception is dynamic
     * @param  string $msg  Message for the exception
     * @throws Zend_Cache_Exception
     */
    public static function throwException($msg)
    {
        // For perfs reasons, we use this dynamic inclusion
        require_once 'Div/Db/Distributor/Strategy/Exception.php';
        throw new Div_Db_Distributor_Strategy_Exception($msg);
    }
}